<template>
  <div>
    <!-- 我是诊断记录页面 -->
    <!-- 每个数据后面的v-model对应的数据不准确，未做校对 -->
    <div class="caidanming"><strong>看病就诊 /</strong>诊断记录</div>  
      <div class="title">诊断记录</div>
     <div class="form">
        <el-form
          :model="diagnosticLogout"
          Diagnostic_logout 
          :rules="rules"
          ref="diagnosticLogout"
          label-width="100px"
          class="demo-diagnosticLogout rule"
        >
          <el-row>
            <el-col :span="7">
              <el-form-item label="病人姓名 :" prop="diagnostic_logout_name">
                <el-input v-model="diagnosticLogout.diagnostic_logout_name"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="7">
 <el-form-item label="性别 :" class="xingbie">
          <el-select v-model="diagnosticLogout.diagnostic_logout_sex" placeholder="请选择性别" class="xingbie2">
            <el-option label="男" value="0"></el-option>
            <el-option label="女" value="1"></el-option>
          </el-select>
        </el-form-item>
        </el-col>
<el-col :span="7">
              <el-form-item label="年龄 :" prop="name">
                <el-input v-model="diagnosticLogout.diagnostic_logout_age"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="7" class="tell">
              <el-form-item label="电话 : " prop="diagnostic_logout_phone">
                <el-input v-model="diagnosticLogout.diagnostic_logout_phone"></el-input>
              </el-form-item>
            </el-col>
            
          </el-row>
          <el-row>

             <!-------------------------------- 模态框分界线 ----------------------------------------->
            <el-button  @click="dialogFormVisible = true" plain class="kaiyao">开药</el-button>
              <div class="motaikuang">
          <el-dialog title="处方药品" :visible.sync="dialogFormVisible" width="950px">
            <el-form :model="form">
      <div class="section2">
        <el-table
          ref="multipleTable"
          :data="newList"
          tooltip-effect="dark"
          style=" font-size:13px"
          @selection-change="handleSelectionChange"
          :row-style="{height:'60px'}"
          :header-cell-style="{color:'',borderBottom:'2px solid #39b9ae'}"
        >
          <!-- 勾选框 -->
                  <el-table-column
                    type="selection"
                    width="50"
                  ></el-table-column>
                  <el-table-column
                    prop="drug_name"
                    label="药品名称"
                    width="210"
                  ></el-table-column>
                  <el-table-column
                    prop="drug_quantity"
                    label="药品规格"
                    width="210"
                  ></el-table-column>
                  <el-table-column
                    prop="pharmaceutical_manufacturer"
                    label="生产厂家"
                    width="210"
                  ></el-table-column>
                  <el-table-column
                    prop="drug_price"
                    label="药品单价"
                    width="210"
                  ></el-table-column>
                </el-table>
        <!-- 分页 -->
         <div class="paging">
          <el-pagination
            @current-change="handleCurrentChange"
            :current-page.sync="currentPage"
            :page-size="pageNum"
            layout="prev, pager, next, jumper"
            :total="drugList"
          ></el-pagination>
        </div>
      </div>
            </el-form>
            <div slot="footer" class="dialog-footer">

                <el-button @click="dialogFormVisible = false" class="btnbtn">取 消</el-button>
                <el-button type="primary" @click="save()" class="btnbtn">确 定</el-button>
    
            </div>
          </el-dialog>
        </div>
        <!-------------------------------- 结束分割线 ----------------------------------------->
            <el-col :span="8">
              <el-form-item label="病症 :" class="bingzheng" prop="name">
                 <el-input  v-model="diagnosticLogout.diagnostic_logout_explain"></el-input>
              </el-form-item>
            </el-col>
             <el-col :span="8" class="feiyong">
              <span style="color:#fff;">1</span>
            </el-col>
            <el-col :span="8" class="kanbing">
              <el-form-item label="看病时间 : " class="time">
          <el-col :span="5">
            <el-form-item>
                <el-date-picker
                  format="yyyy 年 MM 月 dd 日"
                  value-format="yyyy-MM-dd"
                  type="date"
                  placeholder="选择日期"
                  v-model="diagnosticLogout.diagnostic_logout_time"
                  style="width: 100%"
                ></el-date-picker>
              </el-form-item>
          </el-col>
          <el-col class="line" :span="0.5">-</el-col>
          <el-col :span="5" class="linetime">
            <el-form-item>
              <el-time-picker placeholder="选择时间" v-model="form.date2" style="width: 100%;"></el-time-picker>
            </el-form-item>
          </el-col>
        </el-form-item>
            </el-col>
          </el-row>
 <el-form-item label="处方 : " class="chufang">
            <el-input type="textarea" v-model="diagnosticLogout.diagnostic_logout_recipe"></el-input>
          </el-form-item>
          <el-form-item label="备注 : " class="beizhu">
            <el-input type="textarea" v-model="diagnosticLogout.diagnostic_logout_note"></el-input>
          </el-form-item>
         
          <el-form-item label="费用 : " prop="diagnostic_logout_diagnose"><span class="prices">111</span>
               
                <!-- <el-input v-model="diagnosticLogout.jiage"></el-input> -->
              </el-form-item>
           <el-form-item class="anniu" style="margin-right:200px;">
            <el-button type="primary" @click="submitForm('diagnosticLogout')" icon="el-icon-plus" class="btnbtn2"
            >保存</el-button>
            <el-button @click="resetForm('diagnosticLogout')" class="btnbtn1">取消</el-button>
          </el-form-item>
        </el-form>
      </div>
  </div>
</template>

<script>
import axios from 'axios';
export default {
  data() {
    return {
      dialogFormVisible: false,
      form: {
        name: '',
        age: '',
        xingbie: '',
        bingzheng: '',
        chufang: '',
        tell: '',
        dizhi: '',
        date1: '',
        date2: '',
        yishi: '',
        beizhu: '',
        type: [],
       
      },
      formLabelWidth: '120px',

      // 数据
      diagnosticLogout: {
        diagnostic_logout_name:'',
        diagnostic_logout_phone:'',
        diagnostic_logout_sex:'',
        diagnostic_logout_age:'',
        diagnostic_logout_time:'',
        diagnostic_logout_explain:'',
        diagnostic_logout_note:'',
        diagnostic_logout_diagnose:''
      },
      changjiajs: {},
      fenleijs:{},
      jixingjs:{},
      newList:[],
       currentPage: 1,
        pageNum: 6,
          drugList: 0,
        rules: {
        name1: [
          { required: true, message: '请输入活动名称', trigger: 'blur' },
          // { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' },
        ],
        // region: [
        //   { required: true, message: '请选择活动区域', trigger: 'change' },
        // ],
        date1: [
          {
            type: 'date',
            required: true,
            message: '请选择日期',
            trigger: 'change',
          },
        ],
        date2: [
          {
            type: 'date',
            required: true,
            message: '请选择时间',
            trigger: 'change',
          },
        ],
        // desc: [{ required: true, message: '请填写备注', trigger: 'blur' }],
      },
    };
  },
  methods:{
    save(){
      console.log(this._data.newList);
    },
    submitForm(){
      alert(222);
      console.log(this._data.newList);
      debugger;
      axios
        .post('/api/diagnoseController/addDiagnose',{
          diagnose_age: "string",
          diagnose_comment: "string",
          diagnose_disease: "string",
          diagnose_id: 0,
          diagnose_map: "string",
          diagnose_name: "string",
          diagnose_phone: "string",
          diagnose_prescription: "string",
          diagnose_sex: "string",
          diagonse_createtime: "string",
          doctor_id: 0
        })
        .then((r) => {
          console.log(r);
          this.newList = r.data.data;
        });
    },
      // 当页数变化时触发
    handleSelectionChange(val) {
      this.multipleSelection = val;
      console.log(val);
    },
       // 当前页变化时触发
    handleCurrentChange(val) {
      // this.getPage(val);

      console.log(this._data);
      this._data.index1 = parseInt(val);
      // let num=parseInt(val);
      axios
        .get('/api/drug/findAllDrugs', {
          params: {
            diagnosticLogout: this._data.filterText,
            drug_classification_control_id: '',
            pageIndex: this._data.index1,
            pageCount: 6,
          },
        })
        .then((r) => {
          console.log(r);
          this.newList = r.data.data;
        });
    },
    submitForm(){
        alert("111");
        console.log(this._data.diagnosticLogout)
    }
  },
  mounted(){
     //  获取到的总数据分页
     axios.get('/api/drug/findAllDrugs', {
          params: {
            diagnosticLogout: this._data.filterText,
            drug_classification_control_id: '',
            pageIndex: this._data.index1,
            pageCount: 6,
          },
        })
        .then((r) => {
          console.log(r);
          this.newList = r.data.data;
        });
    
  }
};
</script>
<style scoped>
.el-input >>> .el-input__inner {
  width: 160px;
}
.age {
  position: relative;
  top: -63px;
  left: 280px;
}
.xingbie {
  /* width: 120px; */
  position: relative;
  top: -63px;
  left: 0px;
}
.xingbie2 {
  width: 160px;
}
.tell {
  position: relative;
  top: 3px;
  left: 0px;
}

.bingzheng {
  position: relative;
  top: -30px;
  left: 0px;
}
.bingzheng >>> .el-input__inner {
  width: 340px;
}
.yishi {
  position: relative;
  top: -125px;
  left: 0px;
}
.kanbing{
  position: relative;
  top: 0px;
  left: -740px;
}
.time {
  position: relative;
  top: -100px;
  left: 295px;
}
.line{
   position: relative;
  top: 0px;
  left:105px;
}
.linetime{
   position: relative;
  top: 0px;
  left: 110px;
}
.chufang {
  width: 950px;
  position: relative;
  top: -20px;
  left: 0px;
}
.chufang >>> .el-textarea__inner {
  height: 100px;
}
.beizhu {
  width: 950px;
  position: relative;
  top: -10px;
  left: 0px;
}
.anniu {
  width: 400px;
  position: relative;
  top: 90px;
  left: 800px;
  
}
/* 替换原生的css样式 */
.anniu >>>.el-form-item__content{
  margin-left: 0;
}
.xingbie{
   position: relative;
  top: 0px;
  left: 0px;
}
.feiyong{
   position: relative;
  top: -30px;
  left: 300px;
}
.ww{
  
  width: 150px;
  height: 35px;
  border: 1px solid red;
}
.kaiyao{
    position: relative;
  top: -60px;
  left: 880px;
}
.paging {
  margin-top: 30px;
  margin-left: 30%;
}
.prices{
  color: red;
  font-weight: bolder;
}
.btnbtn1 :hover{
color:#39b9ae;
}
.btnbtn2{
  background-color: #39b9ae;
  border:1px solid #39b9ae;
}
/* 外边距的顺序: 上 左 下 右 */
.caidanming {
  margin: 10px 0px 10px 10px;
}
.title {
  font-size: 30px;
  margin-top: 20px;
  font-weight: bold;
  margin: 20px 50px 25px 10px;
}
</style>